# Contributor: Dmitry Zakharchenko <dmitz@disroot.org>
# Maintainer: Dmitry Zakharchenko <dmitz@disroot.org>
pkgname=exercism
pkgver=3.0.13
pkgrel=3
pkgdesc="Command-line client for exercism.io"
url="https://github.com/exercism/cli"
arch="all"
license="MIT"
makedepends="go"
options="!check"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
builddir="$srcdir"/cli-$pkgver

prepare() {
	default_prepare

	go mod edit -replace=github.com/fsnotify/fsnotify=github.com/fsnotify/fsnotify@v1.5.1
	go get -d github.com/fsnotify/fsnotify@v1.5.1
}

build() {
	export GOPATH="$srcdir"
	export GOFLAGS="$GOFLAGS -modcacherw"

	go build -o bin/exercism exercism/main.go
}

package() {
	install -Dm755 bin/exercism "$pkgdir"/usr/bin/exercism

	install -Dm644 shell/exercism_completion.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 shell/exercism.fish \
		"$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 shell/exercism_completion.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
559886abe6325295fbd2b469c6cf06321fcf04d1593870d5db7df1cd33f94d38acc846edd80c70de6e7eb4dde881102792a7a052179665468f99559bac382e24  exercism-3.0.13.tar.gz
"
